﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LenderClearingHouse
{
    public partial class EscrowEditControl : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                object closeDate = edRECORDED_F.DbSelectedDate;
                SetEnable(closeDate);
            }
          

        }

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            this.DataBinding += new EventHandler(EscrowEditControl_DataBinding);
        }

        void EscrowEditControl_DataBinding(object sender, EventArgs e)
        {
            object closeDate = DataBinder.Eval(DataItem, "RECORDED_F");
            SetEnable(closeDate);
        }

        private void SetEnable(object closeDate)
        {
            if (closeDate == System.DBNull.Value || closeDate == null || closeDate.ToString() == "")
            {
                edListingAgreement.Enabled = false;
                edContractDate.Enabled = false;
                edBuyerSign.Enabled = false;
                edECOE_B.Enabled = false;
                edSellerSign.Enabled = false;
                edRecorded_B.Enabled = false;
                edDocsIn.Enabled = false;
                //edBuyerPurchasePrice.Enabled = false;
                edWalkThrough.Enabled = false;
                edPurchaseType.Enabled = false;
                edLender.Enabled = false;
                edIncentive.Enabled = false;
                edCOOPAgent.Enabled = false;
                edHOAManagement.Enabled = false;
                edBuyerName.Enabled = false;
                edMonthlyHOADues.Enabled = false;
                edTitleCompanyBack.Enabled = false;
                edPastDueHOA.Enabled = false;
                edResalePkgToAgent.Enabled = false;
                edResalePacketOrdered.Enabled = false;
                edCommentsBack.Disabled = true;
            }
            else
            {
                edListingAgreement.Enabled = true;
                edContractDate.Enabled = true;
                edBuyerSign.Enabled = true;
                edECOE_B.Enabled = true;
                edSellerSign.Enabled = true;
                edRecorded_B.Enabled = true;
                edDocsIn.Enabled = true;
                //edBuyerPurchasePrice.Enabled = false;
                edWalkThrough.Enabled = true;
                edPurchaseType.Enabled = true;
                edLender.Enabled = true;
                edIncentive.Enabled = true;
                edCOOPAgent.Enabled = true;
                edHOAManagement.Enabled = true;
                edBuyerName.Enabled = true;
                edMonthlyHOADues.Enabled = true;
                edTitleCompanyBack.Enabled = true;
                edPastDueHOA.Enabled = true;
                edResalePkgToAgent.Enabled = true;
                edResalePacketOrdered.Enabled = true;
                edCommentsBack.Disabled = false;
            }

        }

        object _dataItem = null;

        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
            }
        }

        /// <summary>
        /// edPurchaseAgreementReceived control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edPurchaseAgreementReceived;

        /// <summary>
        /// edEffectiveDateBank control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edEffectiveDateBank;

        /// <summary>
        /// edCAP control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edCAP;

        /// <summary>
        /// edECOE_F control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edECOE_F;

        /// <summary>
        /// edTitleCompanyFront control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edTitleCompanyFront;

        /// <summary>
        /// edAdjPurchasePrice control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadNumericTextBox edAdjPurchasePrice;

        /// <summary>
        /// edLoan control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edLoan;

        /// <summary>
        /// edRECORDED_F control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edRECORDED_F;

        /// <summary>
        /// edLoanInfo control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edLoanInfo;

        /// <summary>
        /// edCommentsFront control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::System.Web.UI.HtmlControls.HtmlTextArea edCommentsFront;

        /// <summary>
        /// edListingAgreement control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edListingAgreement;

        /// <summary>
        /// edCommentsBack control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::System.Web.UI.HtmlControls.HtmlTextArea edCommentsBack;

        /// <summary>
        /// edContractDate control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edContractDate;

        /// <summary>
        /// edBuyerSign control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edBuyerSign;

        /// <summary>
        /// edECOE_B control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edECOE_B;

        /// <summary>
        /// edSellerSign control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edSellerSign;

        /// <summary>
        /// edRecorded_B control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edRecorded_B;

        /// <summary>
        /// edDocsIn control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edDocsIn;

        /// <summary>
        /// edBuyerPurchasePrice control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadNumericTextBox edBuyerPurchasePrice;

        /// <summary>
        /// edWalkThrough control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edWalkThrough;

        /// <summary>
        /// edPurchaseType control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edPurchaseType;

        /// <summary>
        /// edLender control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edLender;

        /// <summary>
        /// edIncentive control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edIncentive;

        /// <summary>
        /// edCOOPAgent control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edCOOPAgent;

        /// <summary>
        /// edHOAManagement control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edHOAManagement;

        /// <summary>
        /// edBuyerName control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edBuyerName;

        /// <summary>
        /// edMonthlyHOADues control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadNumericTextBox edMonthlyHOADues;

        /// <summary>
        /// edTitleCompanyBack control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edTitleCompanyBack;

        /// <summary>
        /// edPastDueHOA control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edPastDueHOA;

        /// <summary>
        /// edResalePkgToAgent control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadTextBox edResalePkgToAgent;

        /// <summary>
        /// edResalePacketOrdered control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        public global::Telerik.Web.UI.RadDatePicker edResalePacketOrdered;
    }
}